package com.xdtech.sys.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.sql.Timestamp;

import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.Task;

import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2015-05-10 23:05:41
 * @since 1.0
 * @see
 */
public class TaskItem extends BaseItem implements Serializable{
	private static final long serialVersionUID = 1L;
	private Long id;
	@GridColumn(title="名称",width=100)
	private String name;
	@GridColumn(title="状态",width=100,formatter={"0=<span style=\"color:red;\">停止</span>","1=<span style=\"color:green;\">运行</span>"})
	private String status;
	@GridColumn(title="任务组",width=100)
	private String taskGroup;
	@GridColumn(title="CRON表达式",width=100)
	private String cron;
	@GridColumn(title="执行bean名称",width=100)
	private String target;
	@GridColumn(title="执行bean方法",width=100)
	private String method;
	@GridColumn(title="任务备注",width=100)
	private String remark;

	public void setId(Long id) {
		this.id = id;
		addQuerys("id", id);
	}
	public Long getId() {
		return id;
	}
	
	public void setName(String name) {
		this.name = name;
		addQuerys("name", name);
	}
	public String getName() {
		return name;
	}
	
	public void setStatus(String status) {
		this.status = status;
		addQuerys("status", status);
	}
	public String getStatus() {
		return status;
	}
	
	public void setCron(String cron) {
		this.cron = cron;
		addQuerys("cron", cron);
	}
	public String getCron() {
		return cron;
	}
	
	public void setTarget(String target) {
		this.target = target;
		addQuerys("target", target);
	}
	public String getTarget() {
		return target;
	}
	
	
	public String getTaskGroup()
	{
		return taskGroup;
	}
	public void setTaskGroup(String taskGroup)
	{
		this.taskGroup = taskGroup;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getMethod()
	{
		return method;
	}
	public void setMethod(String method)
	{
		this.method = method;
	}
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static TaskItem createItem(Task task) {
		TaskItem taskItem = new TaskItem();
		BeanUtils.copyProperties(taskItem, task);
		//自定义属性设置填充
		return taskItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<TaskItem> createItems(List<Task> tasks) {
		List<TaskItem> taskItems = new ArrayList<TaskItem>();
		for (Task task : tasks) {
			taskItems.add(createItem(task));
		}
		return taskItems;
	}
}
